using NUnit.Framework;
using ValidationFramework;

namespace ExampleLibraryCSharp.PropertyValidationManagerExamples
{

	public class ExternalExample
	{
		#region Example
		public class Person
		{
			[RequiredIntRule]
			public int Age
			{
				get;
				set;
			}
		}


		[TestFixture]
		public class ExampleUsage
		{
			[Test]
			public void Run()
			{
				var person = new Person();
				var propertyValidationManager = ValidationManagerFactory.GetPropertyValidationManager(person);
				// Could have called propertyValidationManager.Validate() here to validate all
				// properties 
				propertyValidationManager.Validate("Age");
				Assert.IsFalse(propertyValidationManager.IsValid);
				person.Age = 99;
				// Could have called propertyValidationManager.Validate() here to validate all 
				// properties 
				propertyValidationManager.Validate("Age");
				Assert.IsTrue(propertyValidationManager.IsValid);
			}
		}
		#endregion
	}
}